package com.yang.booking.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yang.booking.dao.StaffRestMapper;
import com.yang.booking.pojo.StaffRest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class StaffRestService  {

    @Autowired
    private StaffRestMapper staffRestMapper;

    public Map<String, Object> createStaffRest(String staffId, String RestDate, String RestTime){

        StaffRest staffRest = new StaffRest();
        staffRest.setStaffId(staffId);
        staffRest.setRestDate(RestDate);
        staffRest.setRestTime(RestTime);
        staffRest.setCreateAt(new Date());
        staffRest.setUpdateAt(new Date());
        staffRestMapper.insert(staffRest);

        Map<String, Object> msg = new HashMap<String, Object>();
        msg.put("massage", "创建成功");
        msg.put("code", 200);
        return msg;
    }

    public Map<String, Object> deleteStaffRest(String staffId, String RestDate, String RestTime){

        QueryWrapper<StaffRest> wrapper = new QueryWrapper<>();
        wrapper.eq("staff_id", staffId);
        wrapper.eq("rest_date", RestDate);
        wrapper.eq("rest_time", RestTime);
        staffRestMapper.delete(wrapper);

        Map<String, Object> msg = new HashMap<String, Object>();
        msg.put("massage", "成功");
        msg.put("code", 200);
        return msg;
    }
}
